#include <iostream>
#include <vector>
using namespace std;

const int MAX = 20;
int dp[1 << MAX][MAX];
int gh[MAX][MAX];
int n = 0;

int most_short(int status, int u)
{
	if (dp[status][u] != -1) {
		return dp[status][u];
	}

	if (status == ((1 << n) - 1)) {
		return gh[u][0];
	}
	int ans = INT32_MAX;
	for (int i = 1; i < n; i++) {
		if ((status & (1 << i)) == 0) {
			ans = min(ans, gh[u][i] + most_short(status | (1 << i), i));
		}
	}

	return dp[status][u] = ans;
}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> gh[i][j];
		}
	}

        for(int i = 0; i < (1 << MAX); i++){
                for(int j = 0; j < MAX; j++){
                        dp[i][j] = -1;
                }

        }
	cout << most_short(1, 0) << endl;
	return 0;
}